﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.77    组织机构信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_SYS_ORG: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_SYS_ORG()
		{}
		#region Model
		private long _id;
		private string _orgno;
		private string _intno;
		private string _orgname;
		private string _telcode;
		private string _tel;
		private string _telsub;
		private string _faxcode;
		private string _fax;
		private string _addr;
		private string _postno;
		private string _principalname;
		private long _principalid;
		private string _mobile;
		private long _pid;
		private int _issite=0;
		private string _remark;
        private string _createBy;
        private DateTime? _createDate;
        private string _modifyBy;
        private DateTime? _modifyDate;

		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 组织机构编号
		/// </summary>
		[DataMember]
		public string ORGNO
		{
			get{return _orgno;}
			set{
				if ( _orgno!= value)
				{
					 _orgno = value;
					OnPropertyChanged("ORGNO");
				}
			}
		}
		/// <summary>
		/// 内部编号上级内部编号+‘.’+本记录ID
		/// </summary>
		[DataMember]
		public string INTNO
		{
			get{return _intno;}
			set{
				if ( _intno!= value)
				{
					 _intno = value;
					OnPropertyChanged("INTNO");
				}
			}
		}
		/// <summary>
		/// 组织机构名称
		/// </summary>
		[DataMember]
		public string ORGNAME
		{
			get{return _orgname;}
			set{
				if ( _orgname!= value)
				{
					 _orgname = value;
					OnPropertyChanged("ORGNAME");
				}
			}
		}
		/// <summary>
		/// 办公电话区号
		/// </summary>
		[DataMember]
		public string TELCODE
		{
			get{return _telcode;}
			set{
				if ( _telcode!= value)
				{
					 _telcode = value;
					OnPropertyChanged("TELCODE");
				}
			}
		}
		/// <summary>
		/// 办公电话
		/// </summary>
		[DataMember]
		public string TEL
		{
			get{return _tel;}
			set{
				if ( _tel!= value)
				{
					 _tel = value;
					OnPropertyChanged("TEL");
				}
			}
		}
		/// <summary>
		/// 办公电话分机号
		/// </summary>
		[DataMember]
		public string TELSUB
		{
			get{return _telsub;}
			set{
				if ( _telsub!= value)
				{
					 _telsub = value;
					OnPropertyChanged("TELSUB");
				}
			}
		}
		/// <summary>
		/// 传真区号
		/// </summary>
		[DataMember]
		public string FAXCODE
		{
			get{return _faxcode;}
			set{
				if ( _faxcode!= value)
				{
					 _faxcode = value;
					OnPropertyChanged("FAXCODE");
				}
			}
		}
		/// <summary>
		/// 传真
		/// </summary>
		[DataMember]
		public string FAX
		{
			get{return _fax;}
			set{
				if ( _fax!= value)
				{
					 _fax = value;
					OnPropertyChanged("FAX");
				}
			}
		}
		/// <summary>
		/// 办公地址
		/// </summary>
		[DataMember]
		public string ADDR
		{
			get{return _addr;}
			set{
				if ( _addr!= value)
				{
					 _addr = value;
					OnPropertyChanged("ADDR");
				}
			}
		}
		/// <summary>
		/// 邮编
		/// </summary>
		[DataMember]
		public string POSTNO
		{
			get{return _postno;}
			set{
				if ( _postno!= value)
				{
					 _postno = value;
					OnPropertyChanged("POSTNO");
				}
			}
		}
		/// <summary>
		/// 组织机构负责人
		/// </summary>
		[DataMember]
		public string PRINCIPALNAME
		{
			get{return _principalname;}
			set{
				if ( _principalname!= value)
				{
					 _principalname = value;
					OnPropertyChanged("PRINCIPALNAME");
				}
			}
		}
		/// <summary>
		/// 组织机构负责人记录ID
		/// </summary>
		[DataMember]
		public long PRINCIPALID
		{
			get{return _principalid;}
			set{
				if ( _principalid!= value)
				{
					 _principalid = value;
					OnPropertyChanged("PRINCIPALID");
				}
			}
		}
		/// <summary>
		/// 组织机构负责人手机
		/// </summary>
		[DataMember]
		public string MOBILE
		{
			get{return _mobile;}
			set{
				if ( _mobile!= value)
				{
					 _mobile = value;
					OnPropertyChanged("MOBILE");
				}
			}
		}
		/// <summary>
		/// 上级组织机构
		/// </summary>
		[DataMember]
		public long PID
		{
			get{return _pid;}
			set{
				if ( _pid!= value)
				{
					 _pid = value;
					OnPropertyChanged("PID");
				}
			}
		}
		/// <summary>
		/// 是否网点0否，1是，默认为0
		/// </summary>
		[DataMember]
		public int ISSITE
		{
			get{return _issite;}
			set{
				if ( _issite!= value)
				{
					 _issite = value;
					OnPropertyChanged("ISSITE");
				}
			}
		}
		
        
        /// <summary>
		/// 描述
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}


       


        /// <summary>
        /// 建档人
        /// </summary>
        [DataMember]
        public string CREATEBY
        {
            get { return _createBy; }
            set
            {
                if (_createBy != value)
                {
                    _createBy = value;
                    OnPropertyChanged("CREATEBY");
                }
            }
        }

        /// <summary>
        ///建档时间
        /// </summary>
        [DataMember]
        public DateTime? CREATEDATE
        {
            get { return _createDate; }
            set
            {
                if (_createDate != value)
                {
                    _createDate = value;
                    OnPropertyChanged("CREATEDATE");
                }
            }
        }

        /// <summary>
        /// 修改人
        /// </summary>
        [DataMember]
        public string MODIFYBY
        {
            get { return _modifyBy; }
            set
            {
                if (_modifyBy != value)
                {
                    _modifyBy = value;
                    OnPropertyChanged("MODIFYBY");
                }
            }
        }

        /// <summary>
        /// 修改时间
        /// </summary>
        [DataMember]
        public DateTime? MODIFYDATE
        {
            get { return _modifyDate; }
            set
            {
                if (_modifyDate != value)
                {
                    _modifyDate = value;
                    OnPropertyChanged("MODIFYDATE");
                }
            }
        }


		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

